﻿using System.Collections.Generic;
using Com.OpenCode.Framework.Core;
using DevExpress.XtraBars.Ribbon;

namespace Com.OpenCode.Framework.DevForm
{
    /// <summary>
    ///     Ribbon的Panel界面
    /// </summary>
    public class RibbonPageGroupUI : RibbonPageGroup, IMenuVisible
    {
        #region 构造函数

        public RibbonPageGroupUI(BuildItemEventArgs args)
        {
            Children=new List<IMenuVisible>();
            args.Plugin.Owner = this;
            AllowTextClipping = false;
            ShowCaptionButton = false;
            Text = args.Plugin.Properties.Get("Text").ToString();
            (args.Owner as RibbonPageUI).Groups.Add(this);
        }

        #endregion

        public List<IMenuVisible> Children { get; private set; } 

        public void CheckVisible()
        {
            Visible = false;
            for (int i = 0; i < Children.Count; i++)
            {
                Children[i].CheckVisible();
                if (ItemLinks[i].Visible)
                {
                    Visible = true;
                }
            }
        }
    }
}